<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">关键字搜索</label>
                            <div class="layui-input-inline">
                                <input type="text" name="searchStr" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit
                                    lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    </div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: '/trialEvaluation/list',
            method: 'POST',
            contentType: 'application/json',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {type: "radio"},
                {
                    field: 'numbering', title: '序号', width: 60, align: 'center', templet: function (d) {
                        return d.LAY_INDEX; //返回序号
                    }
                },
                {field: 'taskNumber', title: '工单号', sort: true, align: 'center', minWidth: 300},
                {field: 'subject', title: '测评名称', sort: true, align: 'center', minWidth: 400},
                {field: 'createTime', title: '发布时间', sort: true, align: 'center', minWidth: 200},
                {field: 'endTime', title: '评级时间', sort: true, align: 'center', minWidth: 150},
                {field: 'joinQuota', title: '测评名额（人）', sort: true, align: 'center', minWidth: 150},
                {field: 'purchasePrice', title: '预计测评费用（元）', sort: true, align: 'center', minWidth: 180},
                {field: 'joinNum', title: '实际报名（人）', sort: true, align: 'center', minWidth: 150},
                {field: 'joinRate', title: '报名率（%）', sort: true, align: 'center', minWidth: 150},
                {field: 'acceptedNum', title: '已验收（人）', sort: true, align: 'center', minWidth: 150},
                {field: 'completionRate', title: '完成率（%）', sort: true, align: 'center', minWidth: 150},
                {field: 'actualRewards', title: '实际测评费用（元）', sort: true, align: 'center', minWidth: 150},
                {field: 'levelANum', title: 'A级（人）', sort: true, align: 'center', minWidth: 150},
                {field: 'levelBNum', title: 'B级（人）', sort: true, align: 'center', minWidth: 150},
                {field: 'levelCNum', title: 'C级（人）', sort: true, align: 'center', minWidth: 150},
            ]],
            limits: [50, 100, 150, 200, 250, 300],
            limit: 50,
            page: true,
            request: {
                pageName: 'pageNum',
                limitName: 'pageSize'
            },
            response: { //定义后端 json 格式，详细参见官方文档
                statusName: 'code', //状态字段名称
                statusCode: '200', //状态字段成功值
                msgName: 'msg', //消息字段
                countName: 'total', //总数字段
                dataName: 'rows' //数据字段
            },
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {

            // console.log("监听搜索操作data=", data)
            // 执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: data.field
            }, 'data');

            return false;
        });

        // 监听表格 行双击事件
        table.on('rowDouble(currentTableFilter)', function (obj) {
            // console.log("选中数据列=", obj.data.id);
            var index = layer.open({
                title: '测评详情',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: true,
                area: ['100%', '100%'],
                content: './join-list.html?evaluationId=' + obj.data.id + "&subjectName=" + obj.data.subject,
                end: function () {

                }
            });
            $(window).on("resize", function () {
                layer.full(index);
            });
        });

        // 监听表格单选框选择
        table.on('radio(currentTableFilter)', function (obj) {
            // console.log("监听表格单线框选择=", obj);
        });

        // 监听下拉框框选择
        table.on('radio(orderStatus)', function (obj) {
            // console.log("监听下拉框框选择=", obj)
        });

    });

    /**
     * 重载表格数据
     */
    function reloadTable() {
        layui.use(['table'], function () {
            let table = layui.table;
            table.reload('currentTableId', {
                url: '/trialEvaluation/list'
            });
        })
    }

</script>

</body>
</html>